package com.example.nettyudp.vo;

import lombok.Data;

import java.util.stream.Stream;

/**
 * @author FDJ,
 * @date 2020/5/26,
 * @time 14:23
 */
@Data
public class MessageVo {
    private String method;
    private String via;
    private String maxForwards;
    private String from;
    private String to;
    private String callId;
    private String cseq;
    private String contact;
    private String expires;
    private String allow;
    private String useragent;
    private String contentLength;

    private String msg;

    public MessageVo(String message) {
        String[] strs = message.split("\r\n");
        Stream.of(strs).forEach(s -> {
            if (s.indexOf("REGISTER") >= 0) {
                method = s;
            }
            if (s.indexOf("Via:") >= 0) {
                via = s;
            }
            if (s.indexOf("From:") >= 0) {
                from = s;
            }
            if (s.indexOf("To:") >= 0) {
                to = s;
            }
            if (s.indexOf("Call-ID:") >= 0) {
                callId = s;
            }
            if (s.indexOf("CSeq:") >= 0) {
                cseq = s;
            }
        });

    }

}
